home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
PROGRAM
/
C_QNA.ARJ
/
CANTASN.TCP
< prev
next >
Wrap
Text File
|
1991-04-01
|
854b
|
19 lines
QUESTION: I keep getting the error "cannot assign 'void near *' to
'int near *'" when I try to compile my C++ program. What am
I doing wrong?
ANSWER: As AT&T defines C++ you cannot assigne a void pointer to a
pointer of another type without casting. This differs from
ANSI C. In ANSI C it is acceptable to assign a void pointer
to a pointer of another type. In C++ it is required to cast
the pointer. For example:
/* ANSI C */ /* AT&T 2.0 C++ */
#include <alloc.h> #include <alloc.h>
void main(void) { void main(void) {
char *foo; char *foo;
foo = malloc(10); foo = (char *) malloc(10);
} }